﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DelegateDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            ////1.多个对象间的方法调用关系 使用委托的方式来实现
            //GreenLighter greenLighter = new GreenLighter();
            //RedLighter redLighter = new RedLighter();
            //Switcher switcher = new Switcher();
            //Lighten lighten = new Lighten(greenLighter.OnLight);
            //lighten += new Lighten(redLighter.OnLight);
            //switcher.OnFlip(lighten);


            GreenLighter greenLighter = new GreenLighter();
            Switcher switcher = new Switcher();
            switcher.lighten = new Lighten(greenLighter.OnLight);
            switcher.OnFlip();
            Console.ReadLine();
            
        }
    }
}
